﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ETWebApiDB
{
    public class ConnFactory
    {

        private static readonly string _CONNREAD = ConfigurationManager.ConnectionStrings["MyETLockContext1"].ConnectionString; //目前统一用一个数据库

        //private static readonly string _CONNWRITE = ConfigurationManager.ConnectionStrings["UserDBTOW"].ConnectionString;//写入修改 删除 数据用这个

         
        private static readonly object _obj = new object();
        private ConnFactory()
        {
        }
        public static IDbConnection CreateConn()
        {
            IDbConnection dbConnection = null;
            if (dbConnection == null)
            {
                lock (ConnFactory._obj)
                {
                    if (dbConnection == null)
                    {
                        dbConnection = new SqlConnection(ConnFactory._CONNREAD);
                        dbConnection.Open();
                    }
                }
            }
            return dbConnection;
        }
         

 
    }
}
